package com.huadao.cart_ccs.modle;

import com.huadao.cart_ccs.base.BaseSerialPortModel;
import com.huadao.cart_ccs.common.ByteUtils;
import com.huadao.cart_ccs.common.ParamsPreferences;
import com.huadao.cart_ccs.data.bo.CommandWord;
import com.huadao.cart_ccs.data.bo.Protocol;
import com.huadao.cart_ccs.data.bo.TemperatureBO;

public class TemperatureModle extends BaseSerialPortModel {

//    private String TAG="温度";

    public void readTemperature(){
        Protocol params= ByteUtils.generateProtocol(CommandWord.read,new byte[]{TemperatureBO.ModularType_Temperature,TemperatureBO.temperature_NO1,TemperatureBO.read},null);
        serialPortRequest(params);
    }

    public void setTemperature(double temperature){
        temperature+=ParamsPreferences.getInstance().getTemperatureAdjust();
        byte[] temperatureBytes=ByteUtils.int2bytesLG(2, (int) (temperature*100));
        Protocol params= ByteUtils.generateProtocol(CommandWord.write,new byte[]{TemperatureBO.ModularType_Temperature,TemperatureBO.temperature_NO1,TemperatureBO.write},temperatureBytes);
        serialPortRequest(params);
    }

    public void closeHeat() {
        Protocol params= ByteUtils.generateProtocol(CommandWord.write,new byte[]{TemperatureBO.ModularType_Temperature,TemperatureBO.temperature_NO1,TemperatureBO.stop},null);
        serialPortRequest(params);
    }
}
